#ifndef __VERTEX_LAYOUT_H__
#define __VERTEX_LAYOUT_H__

#include "IVertexLayout.h"
namespace rkt
{
	struct VertexAttr
	{
		GLint		components;
		GLboolean	normalized;
		GLenum      type;
		GLuint      offset;
		GLuint      loacation;
		VertexAttr():components(0)
			,normalized(GL_FALSE)
			,type(GL_FLOAT)
			,offset(0)
			,loacation(-1)
		{}
	};

	typedef std::vector<VertexAttr> VertextAttrs;

	class VertexLayout : public IVertexLayout
	{
	public:
		static IVertexLayout* create();
		VertexLayout();
		virtual ~VertexLayout();
		virtual unsigned int getVertexDataSize() const {return m_VertexDataSize;}
		virtual bool reset(const VertexElementDecs* pElements,unsigned int elementsCount);
		virtual void begin(void* pdata = NULL);
		virtual void end();
		virtual void release();
		virtual void push(const VertexElementDecs& element);
	public:
		const VertextAttrs& getVertexAttrs(){return m_VertexAttrs;}
	protected:
		void pushVertexAttr(const VertexElementDecs& element);
		unsigned int	m_VertexDataSize;
		VertextAttrs	m_VertexAttrs;
	};
}

#endif